package World;

import java.awt.Color;
import java.awt.Graphics;
import FrameWork.Entity;

public class Tile extends Entity
{
	double oxygen;
	TileType type;
	boolean hasConstruction = false, powered = false;
	public Tile(TileType type,int x,int y)
	{
		super(x,y);
		this.type = type;
		if (type.isSolid())
			Solid = true;
	}
	
	public void draw(Graphics g)
	{
		if (type.getColor() != null)
		{
			g.setColor(type.getColor());
			g.fillRect(pixelX, pixelY, 10, 10);
		}
		if (type == TileType.Interior)
		{
			g.setColor(Color.LIGHT_GRAY);
			g.drawRect(pixelX, pixelY, width-1, height-1);
		}
		//if (!type.isSolid() && oxygen >1)
		//{
		//	int roundedOx = (int) oxygen;
		//	int colorInt = (int) (roundedOx*2.55);
		//	g.setColor(new Color(-colorInt+255,0,roundedOx+155));
		//	g.drawString(""+roundedOx, pixelX, pixelY+10);
		//}
		if (powered && World.showingPower)
		{
			g.setColor(Color.yellow);
			g.drawRect(pixelX, pixelY, width-1, height-1);
		}
	}
	
	public TileType getType()
	{
		return type;
	}
	
	public void setType(TileType type)
	{
		this.type = type;
		if(type.isSolid())
			Solid = true;
		else
			Solid = false;
	}
	
	public void setOxygen(double d)
	{
		this.oxygen = d;
	}
	
	public double getOxygen()
	{
		return oxygen;
	}
	
	public void setHasConstruction(boolean a)
	{
		this.hasConstruction = a;
	}
	
	public boolean hasConstruction()
	{
		return hasConstruction;
	}
	
	public boolean isSolid()
	{
		return Solid;
	}
	
	public void setSolid(boolean a)
	{
		this.Solid = a;
	}
	
	public void setPowered(boolean powered)
	{
		this.powered = powered;
	}
	
	public boolean isPowered()
	{
		return powered;
	}
}

